<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <title>订单列表</title>
    <link rel="icon" href="favicon.ico" type="image/x-icon"/>
<#include "../template/include/assign.ftl">
<#include "../template/include/source.ftl">
<#include "../template/template_listPage.ftl">
    <link href="${web_static}/admin/css/list.css" rel="stylesheet" type="text/css"/>
    <style type="text/css">
        .page {
            float: right;
            padding-top: 15px;
            margin-right: 15px;
        }
    </style>
    <script type="text/javascript">
        $(document).ready(function () {

            if ($.browser.msie && $.browser.version == "6.0") {
                setTimeout(function () {
                    $('#status').val('<#if orderInfoQuery??>${(orderInfoQuery.status)!}</#if>');
                    $('#isPay').val('<#if orderInfoQuery??>${(orderInfoQuery.isPay)!}</#if>');
                    $('#isDelete').val('<#if orderInfoQuery??>${(orderInfoQuery.isDelete)!}</#if>');
                }, 1);
            }
            else
            {
                $('#status').val('<#if orderInfoQuery??>${(orderInfoQuery.status)!}</#if>');
                $('#isPay').val('<#if orderInfoQuery??>${(orderInfoQuery.isPay)!}</#if>');
                $('#isDelete').val('<#if orderInfoQuery??>${(orderInfoQuery.isDelete)!}</#if>');
            }

        <#if actionErrors?? && (actionErrors?size > 0)>
            $.dialog({type:"warn", content:"<#list errorMessages as list>${list}<br></#list>", modal:true, autoCloseTime:3000});
        </#if>

            $('#searchButton').click(function () {
                var startTime = document.getElementById("startTime").value;
                var endTime = document.getElementById("endTime").value;
                $("#dateSpan").html("<span></span>");
                if (endTime != null && endTime != '') {
                    return  compareTime(startTime, endTime);
                }
            });

            $('#exportButton').click(function () {
                var startTime = document.getElementById("startTime2").value;
                var endTime = document.getElementById("endTime2").value;
                $("#dateSpan2").html("<span></span>");
                if (endTime != null && endTime != '') {
                    return  compareTime2(startTime, endTime);
                }
            });
            
             $('.follow-cursor').poshytip({
                    className: 'tip-darkgray',
	                followCursor: true,
	                slide: false
                });
              

        });

        function compareTime(startDate, endDate) {
            var startDateTemp = startDate.split(" ");
            var endDateTemp = endDate.split(" ");

            var arrStartDate = startDateTemp[0].split("-");
            var arrEndDate = endDateTemp[0].split("-");

            var arrStartTime = startDateTemp[1].split(":");
            var arrEndTime = endDateTemp[1].split(":");

            var allStartDate = new Date(arrStartDate[0], arrStartDate[1], arrStartDate[2], arrStartTime[0], arrStartTime[1], arrStartTime[2]);
            var allEndDate = new Date(arrEndDate[0], arrEndDate[1], arrEndDate[2], arrEndTime[0], arrEndTime[1], arrEndTime[2]);

            if (allStartDate.getTime() >= allEndDate.getTime()) {
                $("#dateSpan").html("开始时间不能大于结束时间！");
                return false;
            } else {
                return true;
            }
        }
        function compareTime2(startDate, endDate) {
            var startDateTemp = startDate.split(" ");
            var endDateTemp = endDate.split(" ");

            var arrStartDate = startDateTemp[0].split("-");
            var arrEndDate = endDateTemp[0].split("-");

            var arrStartTime = startDateTemp[1].split(":");
            var arrEndTime = endDateTemp[1].split(":");

            var allStartDate = new Date(arrStartDate[0], arrStartDate[1], arrStartDate[2], arrStartTime[0], arrStartTime[1], arrStartTime[2]);
            var allEndDate = new Date(arrEndDate[0], arrEndDate[1], arrEndDate[2], arrEndTime[0], arrEndTime[1], arrEndTime[2]);

            if (allStartDate.getTime() >= allEndDate.getTime()) {
                $("#dateSpan2").html("开始时间不能大于结束时间！");
                return false;
            } else {
                return true;
            }
        }
        function orderDele(orderId, status) {
            var result = confirm("确认要删除吗？");
            if (result) {
                var url = "${web_base}/game/order_info!delete.htm?orderId=" + orderId + "&status=" + status;
                document.forms[1].action = url;
                document.forms[1].submit();
            }
        }

        function editOrder(orderId) {
            var ordId = $('#orderId').val();
            var status2 = $('#status').val();
            var merchantOrderId2 = $('#merchantOrderId').val();
            var gameAccount2 = $('#gameAccount').val();
            var url = "${web_base}/game/order_info!toEdit.htm?orderId=" + orderId;
            if (ordId != null && ordId != '') {
                url = url + "&ordId=" + ordId;
            }
            if (status2 != null && status2 != '') {
                url = url + "&status=" + status2;
            }
            if (merchantOrderId2 != null && merchantOrderId2 != '') {
                url = url + "&merchantOrderId=" + merchantOrderId2;
            }
            if (gameAccount2 != null && gameAccount2 != '') {
                url = url + "&gameAccount2=" + gameAccount2;
            }
            document.forms[1].action = encodeURI(url);
            document.forms[1].submit();
        }

        function queryTotalPrice() {
            var data = $('#listForm').serialize();
            $.ajax({
                type:"POST",
                async:false,
                url:"${web_base}/game/order_info!queryTotalPrice.htm",
                data:data,
                success:function (msg) {
                    if (msg != undefined && msg != '') {
                        var result = eval("(" + msg + ")");
                        var totalPrice = result.totalPrice;
                        var errorMsg = result.errorMsg;
                        if (totalPrice != undefined && totalPrice != null && totalPrice != '') {
                            $.jBox.success('订单销售总额：'+totalPrice+'（元）','订单总价' );
                        }else
                        {
                            $.jBox.error(errorMsg,'error');
                        }
                    }
                }
            });

        }

        function queryCostTotalPrice() {
            var data = $('#listForm').serialize();
            $.ajax({
                type:"POST",
                async:false,
                url:"${web_base}/game/order_info!queryCostTotalPrice.htm",
                data:data,
                success:function (msg) {
                    if (msg != undefined && msg != '') {
                        var result = eval("(" + msg + ")");
                        var costTotalPrice = result.costTotalPrice;
                        var errorMsg = result.errorMsg;
                        if (costTotalPrice != undefined && costTotalPrice != null && costTotalPrice != '') {
                            $.jBox.success('订单成本总额：'+costTotalPrice+'（元）','订单成本总价' );
                        }else
                        {
                            $.jBox.error(errorMsg,'error');
                        }
                    }
                }
            });
        }

        function queryCostTotalParvalue() {
            var data = $('#listForm').serialize();
            $.ajax({
                type:"POST",
                async:false,
                url:"${web_base}/game/order_info!queryCostTotalParvalue.htm",
                data:data,
                success:function (msg) {
                    if (msg != undefined && msg != '') {
                        var result = eval("(" + msg + ")");
                        var totalParvalue = result.totalParvalue;
                        var errorMsg = result.errorMsg;
                        if (totalParvalue != undefined && totalParvalue != null && totalParvalue != '') {
                            $.jBox.success('订单面值总额：'+totalParvalue+'（元）','订单面值总额' );
                        }else
                        {
                            $.jBox.error(errorMsg,'error');
                        }
                    }
                }
            });
        }

        function queryTotalNum() {
            var data = $('#listForm').serialize();
            $.ajax({
                type:"POST",
                async:false,
                url:"${web_base}/game/order_info!queryTotalNum.htm",
                data:data,
                success:function (msg) {
                    if (msg != undefined && msg != '') {
                        var result = eval("(" + msg + ")");
                        var totalNum = result.totalNum;
                        var errorMsg = result.errorMsg;
                        if (totalNum != undefined && totalNum != null && totalNum != '') {
                            $.jBox.success('商品购买总数：'+totalNum,'购买数量' );
                        }else
                        {
                            $.jBox.error(errorMsg,'error');
                        }
                    }
                }
            });
        }

    </script>

</head>
<body class="list">
<div class="body">
    <div class="listBar">
        <h1><span class="icon">&nbsp;</span>订单列表&nbsp;<span class="pageInfo"></span></h1>
    </div>
    <div style="display: none;" id="validateErrorContainer" class="validateErrorContainer">
        <div class="validateErrorTitle">以下信息填写有误,请重新填写</div>
        <ul></ul>
    </div>
    <form id="inputForm" class="validate" action="${web_base}/game/order_info!export.htm" method="post">
        <div class="operateBar">
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;供应商名称：
            <select name="supplierName" class="formText {required: true}" onchange="sendSupplierName('${(obj.supplierName)!}')">
                <option value="" selected="selected">
                    -请选择供应商名称-
                </option>
            <#if supplyNameList??>
                <#list supplyNameList as obj>
                    <option value="${obj!}">${obj!}</option>
                </#list>
            </#if>
            </select>
            &nbsp;&nbsp;&nbsp;&nbsp;
         工号：<select name="registerAccount" class="formText {required: true}" >
                <option value="" selected="selected">
                    -请选择工号-
                </option>
            <#if accountList??>
                <#list accountList as obj>
                    <option value="${obj.registerAccount!}">${obj.registerAccountName!}：${obj.registerAccount!}</option>
                </#list>
            </#if>
            </select>
            &nbsp;&nbsp;&nbsp;&nbsp;
            下游用户名称：
            <select name="downUserNo" class="formText">
                <option value="" selected="selected">
                    -请选择下游用户名称-
                </option>
            <#if downUserList??>
                <#list downUserList as obj>
                    <option value="${obj.userNo!}">${obj.userName!}</option>
                </#list>
            </#if>
            </select>
            <br/>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            支付状态：<select name="isPay">
            <option value="" selected="selected">-请选择-</option>
            <option value="0">支付失败</option>
            <option value="1">支付成功</option>
            <option value="2">退款失败</option>
            <option value="3">退款成功</option>
        </select>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            订单状态：<select name="status">
            <option value="">-请选择-</option>
            <option value="0">失败</option>
            <option value="1">成功</option>
            <option value="2">处理中</option>
        </select>
            &nbsp;&nbsp;&nbsp;&nbsp;
            &nbsp;&nbsp;&nbsp;&nbsp;
            订单生成时间： <input type="text" id="startTime2" name="createOrderTimeStart"
                           onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"
                           value="${(orderInfoQuery.createOrderTimeStart)!}" class="Wdate" readonly="readonly"> --
            <input type="text" id="endTime2" name="createOrderTimeEnd"
                   onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"
                   value="${(orderInfoQuery.createOrderTimeEnd)!}" class="Wdate" readonly="readonly">
            <input type="submit" id="exportButton" value="导出订单信息"/>
            <span id="dateSpan2" style="color: red"></span>
        </div>
    </form>
	<br/>

<@pageList page=(page!) id="listForm" action="${web_base}/game/order_info!queryList.htm" query="orderInfoQuery" isEmpty=true>
    <div class="operateBar">
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
      订单编号：<input type="text" name="orderInfoQuery.orderId" id="orderId"
                    value="<#if orderInfoQuery??>${(orderInfoQuery.orderId)!}</#if>"
                    onkeyup="this.value=this.value.replace(/\D/g,'')"
                    onafterpaste="this.value=this.value.replace(/\D/g,'')"/>
           &nbsp;&nbsp;&nbsp;
      下游订单号：<input type="text" name="orderInfoQuery.merchantOrderId" id="merchantOrderId"
                     value="<#if orderInfoQuery??>${(orderInfoQuery.merchantOrderId)!}</#if>"/>
        &nbsp;
        工号：<select name="registerAccount" class="formText {required: true}" >
        <#if accountList??>
            <#if orderInfoQuery.registerAccount??>
                <option value="${orderInfoQuery.registerAccount!},${orderInfoQuery.registerAccountName!}" selected="selected">
                ${orderInfoQuery.registerAccountName!}：${orderInfoQuery.registerAccount!}
                </option>
            <#else>
                <option value="" selected="selected">
                    -请选择工号-
                </option>
            </#if>
            <#list accountList as obj>
                <option value="${obj.registerAccount!},${obj.registerAccountName!}">
                    <#if obj.registerAccount??>
                    ${obj.registerAccountName!}：${obj.registerAccount!}
                    <#else>
                    ${obj.registerAccountName!}
                    </#if>
                </option>
            </#list>
        </#if>
    </select>
        &nbsp;
        供应商名称：<select name="supplierName" class="formText {required: true}">
            <#if supplyNameList??>
                <#if supplierName??>
                    <option value="${supplierName!}" selected="selected">
                    ${supplierName!}
                    </option>
                <#else>
                    <option value="" selected="selected">
                        -请选择供应商名称-
                    </option>
                </#if>
                <#list supplyNameList as obj>
                    <option value="${obj!}">${obj!}</option>
                </#list>
            </#if>
        </select>

        <br/>&nbsp;&nbsp;
        玩家游戏账号：<input type="text" name="orderInfoQuery.gameAccount" id="gameAccount"
                      value="<#if orderInfoQuery??>${(orderInfoQuery.gameAccount)!}</#if>"/>
         &nbsp;&nbsp;&nbsp;
    下游商户号：<input type="text" name="orderInfoQuery.contractId" id="contractId"
                      value="<#if orderInfoQuery??>${(orderInfoQuery.contractId)!}</#if>"/>
   &nbsp;&nbsp;&nbsp;&nbsp;
        订单状态：<select name="orderInfoQuery.status" id="status">
        <option value="">-请选择-</option>
        <option value="0">失败</option>
        <option value="1">成功</option>
        <option value="2">处理中</option>
        <option value="3">存疑</option>
    </select>
        &nbsp;&nbsp;&nbsp;
        支付状态：<select name="orderInfoQuery.isPay" id="isPay">
        <option value="" selected="selected">-请选择-</option>
        <option value="0">支付失败</option>
        <option value="1">支付成功</option>
        <option value="2">退款失败</option>
        <option value="3">退款成功</option>
    </select>
   <br>
   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        商品名称：<input type="text" name="orderInfoQuery.goodsName" id="goodsName"
                     value="<#if orderInfoQuery??>${(orderInfoQuery.goodsName)!}</#if>"/>
        &nbsp;订单生成时间：<input type="text" id="startTime" name="orderInfoQuery.createOrderTimeStart"
                       onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"
                       value="${(orderInfoQuery.createOrderTimeStart)!}" class="Wdate" readonly="readonly">&nbsp;--&nbsp;
        <input type="text" id="endTime" name="orderInfoQuery.createOrderTimeEnd"
               onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"
               value="${(orderInfoQuery.createOrderTimeEnd)!}" class="Wdate" readonly="readonly">
        &nbsp;&nbsp;
        <input type="button" class="addButton" onclick="queryTotalPrice();" value="汇总总价" />
        <input type="button" class="addButton" onclick="queryCostTotalPrice();" value="汇总成本" />
        <input type="button" class="addButton" onclick="queryTotalNum();" value="汇总数量" />
        <input type="button" class="addButton" onclick="queryCostTotalParvalue();" value="汇总面值" />
        &nbsp;&nbsp;
        <input type="submit" id="searchButton" class="searchButton" value=""/>
        <span id="dateSpan" style="color: red"></span>
    </div>
    <table class="listTable" border="1">
        <tr>
            <th>
                <span class="sort" name="orderId">订单编号</span>
            </th>
            <th>
                <span class="sort" name="goodsName">商品名称</span>
            </th>
            <th>
                <span class="sort" name="gameAccount">玩家游戏账号</span>
            </th>
            <th>
                <span class="sort" name="buyNum">购买数量</span>
            </th>
            <th>
                <span class="sort" name="totalPrice">总金额(元)</span>
            </th>
            <th>
                <span class="sort" name="">成本额（元）</span>
            </th>
            <th>
                <span class="sort" name="supplyName">供应商</span>
            </th>
            <th>
                <span class="sort" name="registerAccount">工号</span>
            </th>
            <th>
                <span class="sort" name="status">订单状态</span>
            </th>
            <th>
                <span class="sort" name="isPay">支付状态</span>
            </th>
            <th>
                <span class="sort" name="createOrderTime">订单生成时间</span>
            </th>
            <th width="75">操&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;作
            <th/>
        </tr>

        <#if page?? && page.list?? && (page.list?size gt 0)>
            <#list page.list as obj>
                <tr>
                    <td>
                       下游：<a class="follow-cursor" title="${(obj.merchantOrderId)!}" href="#">
                            <#if obj.merchantOrderId?? && obj.merchantOrderId?length gte 17>
                            <#--//截取输出文字的长度-->
                            ${obj.merchantOrderId?substring(0,17)}...
                            <#else>
                            ${(obj.merchantOrderId)!}
                            </#if>
                        </a>
                        <br>
                       	本地：<a class="follow-cursor" title="${(obj.orderId)!}" href="#">
                            <#if obj.orderId?? && obj.orderId?length gte 17>
                            <#--//截取输出文字的长度-->
                            ${obj.orderId?substring(0,17)}...
                            <#else>
                            ${(obj.orderId)!}
                            </#if>
                        </a>
                        <br>
                      	 上游：<a class="follow-cursor" title="${(obj.supOrderId)!}" href="#">
                            <#if obj.supOrderId?? && obj.supOrderId?length gte 17>
                            <#--//截取输出文字的长度-->
                            ${obj.supOrderId?substring(0,17)}...
                            <#else>
                            ${(obj.supOrderId)!}
                            </#if>
                        </a>
                    </td>
                    <td>
                        <a class="follow-cursor" title="${(obj.goodsName)!}" href="#">
                            <#if obj.goodsName?? && obj.goodsName?length gte 8>
                            <#--//截取输出文字的长度-->
                            ${obj.goodsName?substring(0,8)}...
                            <#else>
                            ${(obj.goodsName)!}
                            </#if>
                        </a>
                    </td>
                    <td>
                        <a class="follow-cursor" title="${(obj.gameAccount)!}" href="#">
                            <#if obj.gameAccount?? && obj.gameAccount?length gte 12>
                            <#--//截取输出文字的长度-->
                            ${obj.gameAccount?substring(0,12)}...
                            <#else>
                            ${(obj.gameAccount)!}
                            </#if>
                        </a>
               	    </td>
                    <td align="right">
                       ${(obj.buyNum)!}
                    </td>
                    <td align="right">
                        ${(obj.totalPrice*1.0/1000)?string("0.000")!}
                    </td>
                    <td align="right">
                       ${((obj.goodsCostPrice)*(obj.buyNum)*1.0/1000)?string("0.000")!}
                    </td>
                    <td>
                        <#if obj.supplyName?? && obj.supplyName?length gte 15>
                        <#--//截取输出文字的长度-->
                        ${obj.supplyName?substring(0,15)}...
                        <#else>
                        ${(obj.supplyName)!}
                        </#if>
                    </td>
               		<td>
                        下游：<a class="follow-cursor" title="${(obj.contractId)!}" href="#">
                           <#if obj.contractId?? && obj.contractId?length gte 15>
                           <#--//截取输出文字的长度-->
                           ${obj.contractId?substring(0,15)}...
                           <#else>
                           ${(obj.contractId)!}
                           </#if>
                       </a>
                        <br>
                        上游： <a class="follow-cursor" title="${(obj.registerAccount)!}" href="#">
                           <#if obj.registerAccount?? && obj.registerAccount?length gte 15>
                           <#--//截取输出文字的长度-->
                           ${obj.registerAccount?substring(0,15)}...
                           <#else>
                           ${(obj.registerAccount)!}
                           </#if>
                       </a>
                    </td>
                    
                    <td>
                        <#if obj.status?? && obj.status == "0">
                            失败
                        <#elseif obj.status?? && obj.status == "1">
                            成功
                        <#elseif obj.status?? && obj.status =="2">
                            处理中
                        <#elseif obj.status?? && obj.status =="3">
                            存疑
                        </#if>
                    </td>
                    <td>
                        <#if obj.isPay?? && obj.isPay=="0">
                            支付失败
                        <#elseif obj.isPay?? && obj.isPay=="1">
                            支付成功
                        <#elseif obj.isPay?? && obj.isPay=="2">
                            退款失败
                        <#elseif obj.isPay?? && obj.isPay=="3">
                            退款成功
                        </#if>
                    </td>
                    <td>
                        ${(obj.createOrderTime)!}
                    </td>
                    <td width="75">
                        <#if obj.isDelete?? && obj.isDelete =="1">
                            <span class="spanLink" onclick="editOrder('${(obj.orderId)!}');" title="编辑">[编辑]</span>
                        <#else >
                            [编辑]
                        </#if>
                        <#if (obj.status?? && obj.status == "0" && obj.isPay?? && obj.isPay == "1" && obj.isDelete?? && obj.isDelete =="1") || (obj.reType?? && obj.rePrice?? && obj.rePrice>0) >
                            <a href="${web_base}/game/order_info!refund.htm?orderId=${(obj.orderId)!}&contractId=${(obj.contractId)!}&paymentOrderNo=${(obj.paymentOrderNo)!}&merchantIP=${(obj.merchantIP)!}&totalPrice=${(obj.totalPrice)!}"
                               title="退款">[退款]</a>
                        <#elseif (obj.status?? && obj.status == "0" && obj.isPay?? && obj.isPay == "2" && obj.isDelete?? && obj.isDelete =="1") || (obj.reType?? && obj.rePrice?? && obj.rePrice>0) >
                            <a href="${web_base}/game/order_info!refund.htm?orderId=${(obj.orderId)!}&contractId=${(obj.contractId)!}&paymentOrderNo=${(obj.paymentOrderNo)!}&merchantIP=${(obj.merchantIP)!}&totalPrice=${(obj.totalPrice)!}"
                               title="退款">[退款]</a>
                        <#else>
                            [退款]
                        </#if>
                        <br>
                        <a href="${web_base}/game/order_info!detail.htm?orderId=${(obj.orderId)!}" title="详情">[详情]</a>
                        <#if obj.isDelete?? && obj.isDelete =="1">
                            <span class="spanLink" onclick="orderDele('${(obj.orderId)!}','${(obj.status)!}');"
                                  title="删除">[删除]</span>
                        <#else>
                            [删除]
                        </#if>
                        <br>
                            <#if obj.userhandleResult?? && obj.synOrAsy?? && obj.userhandleResult !="SUCCESS" && obj.synOrAsy == "1">
                            <a href="${web_base}/game/order_info!manualNotify.htm?orderId=${(obj.orderId)!}" title="手动通知">[手动通知]</a>
                        <#else>
                            [手动通知]
                        </#if>

                    </td>
                </tr>
            </#list>
        </#if>
    </table>

    <#if page?? && page.list?? && (page.list?size <= 0)>
        <div class="noRecord">
            没有找到任何记录!
        </div>
    </#if>
</@pageList>
</div>

</body>
</html>